import { SelectControlSchema } from 'amis/lib/renderers/Form/Select'
import serverSelectUtils, { ServerSelectUtilsProps } from '@/components/amis/ServerSelectUtils/serverSelectUtils'
import accountAdminApiConfig from '@/core/account/generated/apiconfig/accountAdminApiConfig'
import lodash from 'lodash'

class IamAppIdSelectUtils {
	getSchema = (parmas?: Partial<ServerSelectUtilsProps>): SelectControlSchema => {
		const mergeProps = lodash.merge(
			{
				label: '账户应用',
				name: 'iamAppId',
				labelField: 'title',
				valueField: 'id',
				searchField: 'title',
				detailApiConfig: accountAdminApiConfig.iamApplication.get,
				searchApiConfig: accountAdminApiConfig.iamApplication.search,
			} as ServerSelectUtilsProps,
			parmas,
		)
		return serverSelectUtils.getSchema(mergeProps)
	}
}

export default new IamAppIdSelectUtils()
